home *** CD-ROM | disk | FTP | other *** search
- (*
- REFORMAT.INC
- Inline code for Int25 and Int26 procedures, REFORMAT.PAS
- Author David Kirschbaum (ABN.ISCAMS@USC-ISID) May 86.
- REFORMAT.PAS author Jos Wennmacker (URC) apr '86.
-
- Rather than force the user to go through the assembly routine and keep
- track of a bogus .COM file, I've used INLINE and two different hacks of
- the original .ASM code to create Turbo Pascal inline code.
-
- Since we only use one Register record variable, AND it's a global one,
- I stripped out passing its address as a parameter and just rely on it
- being in the DS data segment.
-
- Because the code is so redundant (only the interrupt number is different),
- I combined the two procedures, Int25 and Int26, into a new single procedure,
- Int2526. Now you must pass the interrupt number you desire (25H or 26H).
- I resisted (with difficulty) the temptation for a little self-modifying code,
- rather than listen to the screams on the networks!
-
- To use the new procedures, comment out the two external procedures:
- Int25(....); External Int25.Com;
- Int26(....); External Int26.Com;
-
- and add the new .INC file
- {$I REFORMAT.INC} in their place.
-
- The separate Int25 and Int26 procedures are commented out but still remain
- below for your edification. To use them, go through REFORMAT.PAS and change:
- Int25(Register); to Int25; (the read function), and
- Int26(Register); to Int26; (the write function).
- (and of course, uncomment Int25 and Int26 below, and comment out Int2526!)
-
- To use the new single procedure, in REFORMAT.PAS change:
- Int25(Register); to Int2526($25); (the read function), and
- Int26(Register); to Int2526($26); (the write function).
-
- This code (plus other changes I made to REFORMAT.PAS to tighten and speed
- it up a little) runs perfectly on an XT clone (Gulfstream Micro Systems
- 80286 with a 10 Meg hard disk, 5.25" floppy, PC-DOS 3.1).
-
- Full credit, honors and glory for REFORMAT.PAS to the original author.
- This extension is released to the Public Domain with no constraints.
-
- David Kirschbaum, Toad Hall
- ABN.ISCAMS@USC-ISID.ARPA
- 3 May 86
-
- The following is extracted from INT25.ASM which accompanied REFORMAT.PAS.
- I've placed here so you can see just what the inline code is trying to do.
- INT26.ASM had about the same header.
-
- title Int25 called from Turbo Pascal.
- subttl Jos Wennmacker (URC) apr '86
- page 60,132
- ;
- ; Performs random sector read from diskette or disk.
- ;
- ; This routine must be called from TURBO
- ; as follows: Int25(Regs);
- ; Regs is of type
- ;
- ; RegPack: record case integer of
- ; 1: (ax, bx, cx, dx, bp, si, di, ds, es, flags : integer):
- ; 2: (al, ah, bl, bh, cl, ch, dl, dh : byte)
- ; end;
- ;
- ; Before calling this routine the Regs must be set as follows:
- ;
- ; al := DriveNumber;
- ; cx := NumberOfSectorsToRead;
- ; dx := FirstSectorNumber;
- ; ds := seg(DTArea);
- ; bx := ofs(DTArea);
- ;
- ; The drivenumber must be specified as: 0 = A, 1 = B.
- ; Upon return to TURBO the registers in Regs are set to
- ; the values they had after int 25H returned.
- ;
- dsect segment at SP+
- AXreg label word 0
- ALreg db ?
- AHreg db ?
- BXreg label word 2
- BLreg db ?
- BHreg db ?
- CXreg label word 4
- CLreg db ?
- CHreg db ?
- DXreg label word 6
- DLreg db ?
- DHreg db ?
- BPreg dw ? 8
- SIreg dw ? 10
- DIreg dw ? 12
- DSreg dw ? 14
- ESreg dw ? 16
- Flags dw ? 18
- dsect ends
- *)
-
- (*
- PROCEDURE Int25;
- {the separate read procedure}
- BEGIN
- Inline(
- $1E { push ds ; save what we are about to clobber}
- /$BE/>REGISTER { mov si,>Register ; load DS:Regs (global) address}
- /$8A/$04 { mov al,byte ptr[si] ;Regs.al}
- /$8B/$5C/$02 { mov bx,[si+2] ;Regs.bx}
- /$8B/$4C/$04 { mov cx,[si+4] ;Regs.cx}
- /$8B/$54/$06 { mov dx,[si+6] ;Regs.dx}
- /$56 { push SI ;save Regs addr}
- /$8B/$74/$0E { mov si,[si+14] ;Regs.DS}
- /$8E/$DE { mov ds,si ;DS=Regs.DS}
- /$55 { push bp ; DOS destroys it}
- /$FC { cld ; if you don't, DOS makes a mess!}
- /$CD/$25 { int $25 ; old flags are still on the stack!}
- /$5F { pop DI ;so save them here a sec}
- /$5D { pop BP}
- /$5E { pop SI ;Regs addr}
- /$1F { pop DS ;Regs seg}
- /$9C { pushf ;move the new flags...}
- /$8F/$44/$12 { pop [si+18] ;into as Reg.Flags}
- /$89/$04 { mov [si],ax ;possible errors}
- /$57 { push DI ;old flags..}
- /$9D { popf ;..restored}
- );
- {BX,CX,DX should not have changed, so no need to post Regs.}
- END; {of Int25}
-
- PROCEDURE Int26;
- {the separate write procedure}
- BEGIN
- Inline(
- $1E { push ds ; save what we are about to clobber}
- /$BE/>REGISTER { mov si,>Register ; load DS:Regs (global) address}
- /$8A/$04 { mov al,byte ptr[si]}
- /$8B/$5C/$02 { mov bx,[si+2]}
- /$8B/$4C/$04 { mov cx,[si+4]}
- /$8B/$54/$06 { mov dx,[si+6]}
- /$56 { push SI ;Regs addr}
- /$8B/$74/$0E { mov si,[si+14] ;Regs.DS}
- /$8E/$DE { mov ds,si}
- /$55 { push bp ; DOS destroys it}
- /$FC { cld ; if you don't PC-DOS makes a mess!}
- /$CD/$26 { int $26 ; flags are still on the stack!}
- /$5F { pop DI ;save old flags here a sec}
- /$5D { pop BP}
- /$5E { pop SI ;DS:SI Regs addr}
- /$1F { pop DS ;DS Regs (global variable) segment}
- /$9C { pushf ;returned flags}
- /$8F/$44/$12 { pop [si+18] ;save as Regs.Flags}
- /$89/$04 { mov [si],ax ;AX has any returned errors}
- /$57 { push DI ;old flags..}
- /$9D { popf ;..restored}
- );
- {BX,CX,DX should not have changed, so no need to post Regs.}
- END; {of Int26}
- *)
-
- PROCEDURE Int2526(R : BYTE);
- {Uses global variable Register. Pass $25 (read) or $26 (write)
- as R for the function you desire.
- }
- BEGIN
- Inline(
- $1E { push ds ; save what we are about to clobber}
- /$BE/>REGISTERs { mov si,>Register ; load DS:Regs (global) address}
- /$8A/$04 { mov al,byte ptr[si] ;Regs.al}
- /$8B/$5C/$02 { mov bx,[si+2] ;Regs.bx}
- /$8B/$4C/$04 { mov cx,[si+4] ;Regs.cx}
- /$8B/$54/$06 { mov dx,[si+6] ;Regs.dx}
- /$56 { push SI ;save Regs addr}
- /$8B/$74/$0E { mov si,[si+14] ;Regs.DS}
- /$8E/$DE { mov ds,si ;DS=Regs.DS}
- /$55 { push bp ; DOS destroys it}
- /$FC { cld ; if you don't, DOS makes a mess!}
- /$80/$BE/>R/$25 { cmp byte ptr >R[BP],$25 ;doing a read?}
- /$75/$05 { jne Do26 ; nope}
- /$CD/$25 { int $25 ; yep, do the read}
- /$E9/$02/$00 { jmp Done ; and skip}
- {Do26:}
- /$CD/$26 { int $26 ;do the write}
- {Done: ;old flags are still on the stack!}
- /$5F { pop DI ;so save them here a sec}
- /$5D { pop BP}
- /$5E { pop SI ;Regs addr}
- /$1F { pop DS ;Regs seg}
- /$9C { pushf ;move the new flags...}
- /$8F/$44/$12 { pop [si+18] ;into as Reg.Flags}
- /$89/$04 { mov [si],ax ;possible errors}
- /$57 { push DI ;old flags..}
- /$9D { popf ;..restored}
- );
- {BX,CX,DX should not have changed, so no need to post Regs.}
- END; {of Int2526}